const mysql = require('mysql');
//创建一个mysql的链接池
const db = mysql.createPool({
    host:'localhost',
    user:'root',
    password:'root',
    database:'jy1608_blog',
    port:8889
})
//查询方法
let query = function(sql){
    return new Promise((resolve,reject)=>{
        db.query(sql,(err,data)=>{
            if(err){
                reject(err);
            }else{
                resolve(data);
            }
        });
    });
}

module.exports = {
    query:query
}
